Skip to content

Hold the standalone identifier marker in the EvaluationContext - #1081

Merged
markt-asf merged 1 commit into
apache:mainfrom
AngeloRubens:el-identifier-context
Oct 16, 2026
Merged

markt-asf merged 1 commit into
apache:mainfrom
AngeloRubens:el-identifier-context

Conversation

@AngeloRubens

Copy link
Copy Markdown
Contributor

AstIdentifier sets ELResolver.StandaloneIdentifierMarker in the context for the resolution of every identifier: TRUE before the resolution of a stand-alone identifier, and back to FALSE after the resolution of every identifier. EvaluationContext passes putContext on to the wrapped ELContext, so each identifier costs one or two updates of the wrapped context's HashMap. Frameworks evaluate many identifiers per request, so these updates add up.

This change holds the marker in a field of the EvaluationContext instead. The resolvers are passed the EvaluationContext, so they still see it, ImportELResolver among them. Two side effects:

  • The marker is no longer left in the application's ELContext after an evaluation (as FALSE).
  • A nested evaluation started while an identifier is being resolved has its own EvaluationContext. It no longer sees the marker of the evaluation that triggered it.

A new test in TestAstIdentifier checks that a resolver sees the marker for ${marked} but not for ${marked.length()}, and that the ELContext does not hold the marker afterwards. The EL tests (**/el/**/Test*.java, including TestImportELResolver) pass.

Measurement

  • Setup: Mojarra's test/perf pages (42 pages) on Tomcat 11.0.25, with Tomcat's EL built from source in each arm, measured A B C C B A on one GitHub Actions runner. C is a replicate of B and serves as the noise reference.
  • Baseline: the 11.0.25 EL with AstIdentifier changed to put the marker the way main does (TRUE only for a stand-alone identifier, FALSE afterwards). I measured this rather than main itself because Mojarra 4.1 targets Jakarta EE 11.
  • Result: total CPU time per request changed by −2.6%, −1.7% and −1.6% in three runs (B vs C noise 0.3%, 0.6% and 1.5%), so about −2% on average. The responses were identical in all arms.
  • Against plain 11.0.25 (which puts the marker twice for every identifier), the same change measured −0.8% and −2.1%.

No changelog entry is included; I can add one if you prefer.

This work was done with Claude Code (Claude Opus 5.5); the commit carries a Co-Authored-By trailer.

🤖 Generated with Claude Code

AstIdentifier sets ELResolver.StandaloneIdentifierMarker for every identifier
it resolves (TRUE for a stand-alone identifier, then back to FALSE). Holding it
in the EvaluationContext, which is what the resolvers are passed, rather than
in the map of the wrapped ELContext saves the map updates of every identifier.
With Mojarra's test/perf pages, this lowers the CPU time per request by about
2%.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants